<template>
  <el-dialog
    v-model="dialogVisible"
    width="375px"
    style="
      background: #222222;
      border-radius: 9px;
      border: 1px solid rgba(255, 255, 255, 0.5);
      padding: 0;
    "
    :modal="false"
    :before-close="close"
    align-center
    @close="close"
  >
    <template #default>
      <div class="title">
        <div>送礼对象：</div>
        <div class="circle">
          <div class="avator"></div>
          <div class="name">时晓晓</div>
        </div>
        <div class="vertical-line"></div>
        <div v-for="i in 12" :class="{ circle: true, active: i === 1 }">
          <div class="avator"></div>
          <div class="name">时晓111</div>
        </div>
      </div>
      <div class="dialog-content">
        <div class="line"></div>
        <div class="tab unselectable">
          <div
            v-for="(item, index) in tabList"
            :key="index"
            :class="{ 'tab-item': true, active: tab === item.value }"
            @click="tab = item.value"
          >
            <span>{{ item.label }}</span>
            <div class="vertical-line"></div>
          </div>
        </div>
        <div class="list-container">
          <div
            v-for="i in 22"
            :class="{ item: true, active: selectValue === i }"
            @click="selectValue = i"
          >
            <img src="@/assets/live/penquan.png" class="pic" />
            <span class="label">爱心漂流瓶</span>
            <div class="num">
              <img :src="iconImg" class="icon" />
              <span>10000</span>
            </div>
          </div>
        </div>
        <div class="footer-btns">
          <img :src="iconImg" class="icon" />
          <span>{{ balance }}</span>
          <span class="btn small unselectable">+充值</span>
          <span style="flex: 1"></span>
          <span
            class="subtract unselectable"
            @click="
              () => {
                if (num === 0) return;
                num--;
              }
            "
          >
            -
          </span>
          <span style="width: 30px; text-align: center">{{ num }}</span>
          <span class="add unselectable" @click="num++">+</span>
          <span class="btn large unselectable m-l-8">赠送</span>
        </div>
      </div>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import iconImg from "@/assets/live/room/crystal.svg";

const dialogVisible = ref(false);
const tabList = ref([
  {
    label: "精品",
    value: 1,
  },
  {
    label: "国潮",
    value: 2,
  },
  {
    label: "游戏",
    value: 3,
  },
]);
const tab = ref(1);
const balance = ref(10600);
const num = ref(0);
const selectValue = ref(1);

// 显示
const show = () => {
  dialogVisible.value = true;
};

// 关闭前的回调
const close = () => {
  dialogVisible.value = false;
};

defineExpose({ show, close });
</script>
<style lang="scss" scoped>
.title {
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  gap: 10px;
  align-items: center;
  padding: 40px 9px 18px;
  .circle {
    padding: 2px;
    border-radius: 50%;
    position: relative;
  }
  .active {
    background: linear-gradient(
      136deg,
      rgba(212.9249945282936, 159.375, 255, 1),
      rgba(176.38074427843094, 155.12500405311584, 255, 1),
      rgba(98.62656533718109, 104.30014729499817, 251.81250303983688, 1)
    );
  }

  .avator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: lightcoral;
  }
  .name {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 223px;
    font-size: 7px;
    // padding: 1px 2px;
    box-sizing: border-box;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 24px;
    transform: translateX(-50%);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
  .vertical-line {
    width: 1px;
    height: 20px;
    background: #d8d8d8;
  }
}
.dialog-content {
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  .line {
    width: 321px;
    height: 1px;
    background-color: rgba(108, 108, 108, 0.4);
  }
  .tab {
    // background-color: pink;
    align-self: flex-start;
    margin-top: 15px;
    display: flex;
    padding-bottom: 10px;
    &-item {
      color: rgba(255, 255, 255, 0.4);
      font-size: 14px;
      padding-left: 26px;
      display: flex;
      align-items: center;
      gap: 26px;
      cursor: default;
    }
    .active {
      color: #fff;
    }
    .vertical-line {
      width: 1px;
      height: 10px;
      background-color: rgba(255, 255, 255, 0.4);
    }
  }
  .list-container {
    width: 100%;
    height: 375px;
    box-sizing: border-box;
    padding: 10px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    overflow-y: scroll;
    overflow-y: scroll; /* 强制显示滚动条轨道（隐藏时仍可滚动） */
    scrollbar-width: none; /* Firefox 隐藏滚动条 */
    -ms-overflow-style: none; /* IE/Edge 隐藏滚动条 */
    .item {
      padding: 8px 12px 10px;
      display: flex;
      flex-direction: column;
      align-items: center;
      .pic {
        width: 60px;
        height: 60px;
      }

      .label {
        font-size: 12px;
        margin-top: 7px;
      }
      .num {
        font-size: 10px;
        color: rgba(255, 255, 255, 0.6);
        display: flex;
        align-items: center;
        .icon {
          width: 10px;
          height: 10px;
        }
      }
    }
    .active {
      background-image: url("@/assets/live/room/gift-border.svg");
      background-size: 100%;
      background-repeat: no-repeat;
    }
  }
  .list::-webkit-scrollbar {
    display: none;
  }
  .footer {
    border-top: 1px solid rgba(216, 216, 216, 0.5);
  }
  .footer-btns {
    width: 100%;
    padding: 16px 14px;
    display: flex;
    align-items: center;
    color: #fff;
    .icon {
      width: 14px;
      height: 14px;
      border-radius: 50%;
    }
    .add,
    .subtract {
      width: 24px;
      height: 24px;
      background-color: #fff;
      border-radius: 8px;
      color: #000;
      text-align: center;
      line-height: 24px;
      font-size: 12px;
    }
    .btn {
      background-image: url("@/assets/live/gradientButton.png");
      background-position: center;
      background-repeat: no-repeat;
      background-size: contain;
      cursor: default;
      font-size: 11px;
    }
    .small {
      padding: 5px 10px;
      margin-left: 7px;
    }
    .large {
      padding: 5px 17px;
      margin-right: 0;
    }
  }
}
</style>
